import { _decorator, Component, Node, Canvas, find } from 'cc';
const { ccclass, property } = _decorator;
import { UiUtil } from '../Framework/Utils/UiUtil';
import { ToastTs } from '../Prefabs/Scripts/ToastTs';
import { EventUtil } from '../Framework/Utils/EventUtil';
import { HttpUtil } from '../Framework/Utils/HttpUtil';

@ccclass('GameApplication')
export class GameApplication extends Component {


    /**
     * 主场景的画布
     */
    canvas: Canvas = null;

    protected onLoad(): void {

        // 查询主场景的画布
        var canvasNode = find("Canvas");
        this.canvas = canvasNode.getComponent(Canvas);

        // this.node.addComponent(ToastTs);
        // 初始化UiUtil工具包
        this.node.addComponent(UiUtil).init(this.canvas);

        // 初始化事件Util工具包
        this.node.addComponent(EventUtil);

        // 初始化Http请求包
        this.node.addComponent(HttpUtil)

        UiUtil.INSTANCE.createPrefabAsset('Prefabs', 'LoginView', Node, null, true, null)

        // setTimeout(() => {
        //     UiUtil.INSTANCE.showToast({ msg: '我的名字叫俞烨', millisecond: 600 })
        // }, 1000)

        // setTimeout(() => {
        //     UiUtil.INSTANCE.controlPrefabAsset('LoginView' , false)
        // }, 3000)

        // setTimeout(() => {
        //      UiUtil.INSTANCE.controlPrefabAsset('LoginView', true )
        // }, 5000)
    }


    protected init(data: any) { }

    public showToast() {
        UiUtil.INSTANCE.showToast({ msg: '出售成功', millisecond: 600 })
    }
}

